package com.niit.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Reservation {
    private String bill_id;
    private String window_id;
    private String consumer_id;
    private String quantity;
    private String total;
    private String dish_name;
    private int reservation_result;
    private String is_display;
    private String status;
    @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
    private String pickup_time; // 将 pickup_time 修改为 String 类型

    private String button_status;

    public LocalDateTime getParsedPickupTime() {
        // 假设格式为yyyy-MM-dd HH:mm:ss
        if (pickup_time == null) {
            throw new IllegalArgumentException("pickup_time cannot be null");
        }

        return LocalDateTime.parse(pickup_time, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
    }
}
